import 'package:dart_amqp/dart_amqp.dart';

void main(List<String> args) {
  print("Start success");
  registerAmqpEvents();
}

void registerAmqpEvents() async {
  var client = Client(settings: ConnectionSettings(
    host: "192.168.1.128",
    port: 5672,
    authProvider: PlainAuthenticator("orange-project", "orange-project"),
  ));

  var channel = await client.channel();
  var exchange = await channel.exchange("Example", ExchangeType.DIRECT, durable: true);

  var storeId = "Server";
  var queue = await channel.queue("", exclusive: false, durable: true, autoDelete: true, );
  queue.bind(exchange, storeId);
  var consumer = await queue.consume();
  consumer.listen((message){
    print(message.payloadAsString);
    exchange.publish(message.payloadAsString, "Client");
  });
}
